package middleware

import (
	"iris-starter/config"
	"iris-starter/datamodels"

	"github.com/kataras/iris/v12"

	"github.com/kataras/iris/v12/middleware/jwt"
)

func JwtVerify() iris.Handler {
	secret := config.Conf.App.JwtSecret
	verifier := jwt.NewVerifier(jwt.HS256, []byte(secret))
	// Enable server-side token block feature (even before its expiration time):
	verifier.WithDefaultBlocklist()
	// Enable payload decryption with:
	// verifier.WithDecryption(encKey, nil)

	return verifier.Verify(func() interface{} {
		return &datamodels.AdminUserClaim{}
	})
}
